package com.fwlst.module_home.activity

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import com.alibaba.android.arouter.facade.annotation.Route
import com.fwlst.module_home.model.MemberViewModel
import com.fwlst.module_home.screen.MemberCenterScreen
import androidx.activity.viewModels


@Route(path = "/home/route/MemberCenterActivity")
class MemberCenterActivity : ComponentActivity() {
    private val viewModel: MemberViewModel by viewModels()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            MemberCenterScreen(viewModel)
        }
    }
    override fun onResume() {
        super.onResume()
        viewModel.updateUserInfo()
        if (viewModel.isAutoCheckout && viewModel.isLogIn.value){
            viewModel.isAutoCheckout = false
            viewModel.preOrder(this)
        }
    }
}